package com.web.dao.impl;

import com.web.dao.BookDAO;
import com.web.entity.Book;
import com.web.util.JDBCUtils;

import java.util.List;

/**
 * @author lenovo
 * @Description
 * @Date2025-3-13 19:48
 */
public class BookDAOImpl implements BookDAO {
    @Override
    public List<Book> selectAllBooks() {
        return JDBCUtils.query(Book.class,"SELECT * from book");
    }

    @Override
    public void insertBook(Book book) {
        JDBCUtils.update(
                "insert into book(bookname,name,price,publishe) values(?,?,?,?)",
                book.getBookname(),book.getName(),book.getPrice(),book.getPublishe());
    }

    @Override
    public void updateBook(Book book) {
        JDBCUtils.update(
                "update book set bookname=?,name=?,price=?,publishe=? where id=?",
                book.getBookname(),book.getName(),book.getPrice(),book.getPublishe(),book.getId());

    }

    @Override
    public void deleteBook(int id) {
        JDBCUtils.update("delete from book where id =?",id);
    }

}
